package com.cn.task;

import com.cn.entity.RunLog;
import com.cn.service.RunLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue;

/**
 * Created by chenyuncong on 2018/8/6.
 */
@Component
public class RunLogSaveConsumer extends SaveConsumer implements ApplicationListener<ContextRefreshedEvent> {

    @Autowired
    private RunLogService runLogService;

    @Autowired
    private MongoTemplate mongoTemplate;

    //初始化监控线程
    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        init();
    }

    @Override
    public void workTask(List list, int saveNum, boolean sign) {
        List<RunLog> rList = list;
        System.out.println(mongoTemplate);
        System.out.println(rList.size());
        System.out.println("save "+countMap);
    }


}
